/*
   Copyright (c) 2019 Shanghai Xuanzi Technology Co. Ltd https://xuanzi.ltd
   XZMindMap is licensed under the Mulan PSL v1.
   You can use this software according to the terms and conditions of the Mulan PSL v1.
   You may obtain a copy of Mulan PSL v1 at:
      http://license.coscl.org.cn/MulanPSL
   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
   PURPOSE.
   See the Mulan PSL v1 for more details.

*/

package xuanzi.openmind.nodes;

import xuanzi.commons.graphics.Canvas;
import xuanzi.commons.graphics.Path;
import xuanzi.openmind.renders.RenderConfig;

public class Icon extends Media{

	String icon ;//= "icon://FONTAWESOME_WEBFONT.icon/uf097";
	
	Path path ;
	
	float size = 20f; 
	
	int color = 0;
	
	int fillColor = 0x0;

	public Icon() {
		// TODO Auto-generated constructor stub
	} 
	
	public Icon(String icon) {
		// TODO Auto-generated constructor stub
		this.icon = icon;
	} 
	
	public void setIcon(String icon) {
		this.icon = icon;
	}
	
	@Override
	public void draw(Canvas canvas) {
		if(icon!=null) { 
			paint.fill(color==0?RenderConfig.primaryColor:color);	
			if(path == null) {
				path = Path.fromIcon(icon,height());
			}
			canvas.save();
			canvas.translate(centerX(), centerY());
			canvas.drawPath(path, paint);
			canvas.restore();
		}else {
			paint.fill(color==0?RenderConfig.primaryColor:color);
			canvas.drawText("😂", centerX(), centerY(), paint);
		}
	//	canvas.drawText("😂", centerX(), centerY(), paint);
		// TODO Auto-generated method stub
	//	super.draw(canvas);
	}
}
